package FileHandling;

import java.io.FileWriter;
import java.io.IOException;
import java.util.Calendar;

/** Handles loading and saving of the mind map database file.
 * 
 * @author Lewis Marhin and John Gray-Spence
 */
public class MasterOps
{
    /**
     * Saves the master list file. A new file is created on each save along with the
     * date, reducing data loss if the master list file is corrupted.
     *
     * @param fname Name of the master list file. Extension not required.
     * @param entries The entries to be written to the file.
     * @return Returns a String containg succesfull/unsuccessful file save message.
     */
    public static String saveMaster( String fname, String entries ) {
        try {
            FileWriter out = new FileWriter ( fname + "_" + Calendar.DATE );
            out.write( entries );
        } catch( IOException e ) {
            return "Error saving MasterList.txt.\nERROR:\n" + e.toString();
        }
        return "Master list file updated successfully.";
    }
    
    /**
     * Loads the Master List file.
     * 
     * @param f Name of the Master List file.
     * @return Confirmation or failure of load message.
     */
    public static String loadMaster( String f ) {
        return "string";
    }
}
